package com.tencet.service.Impl;

import com.tencet.dao.AccountOneDAO;
import com.tencet.dao.TransferDAO;
import com.tencet.dao.impl.AccountOneDAOImpl;
import com.tencet.dao.impl.TransferDAOImpl;
import com.tencet.service.TransferService;

import java.util.List;

/**
 * @author: @date: 2022/7/21 16:08
 * @description:
 */
public class TransferServiceImpl implements TransferService {
    private AccountOneDAO accountOneDAO = new AccountOneDAOImpl();
    private final TransferDAO transferDAO = new TransferDAOImpl();

    /**
     * 判断余额够不够转账
     *
     * @param money
     * @param idOne
     * @return
     */
    @Override
    public boolean trueOrFalse(int money, String idOne) {

        Integer balance = accountOneDAO.getBalanceByIdOne(idOne);
        if (money > balance) {
            System.out.println("到1");
            return false;
        } else {
            System.out.println("到2");
            return true;
        }
    }

    /**
     * 转账
     *
     * @param money
     * @param add_num
     * @param reduce_num
     */
    @Override
    public boolean transfer(int money, String add_num, String reduce_num) {
        return transferDAO.changeBalance(money, reduce_num, add_num);
    }

    @Override
    public List<String> getAddNumByName(String add_name) {
        List<String> add_nums = transferDAO.getCenterByName(add_name);
        return add_nums;
    }


}